package com.appwoo.txtws.component;

import android.net.TrafficStats;
import java.math.BigDecimal;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Arith
{
  private static final int DEF_DIV_SCALE = 10;

  public static double add(double paramDouble1, double paramDouble2)
  {
    return new BigDecimal(Double.toString(paramDouble1)).add(new BigDecimal(Double.toString(paramDouble2))).setScale(2, 4).doubleValue();
  }

  public static double div(double paramDouble1, double paramDouble2)
  {
    return div(paramDouble1, paramDouble2, 10);
  }

  public static double div(double paramDouble1, double paramDouble2, int paramInt)
  {
    if (paramInt < 0)
      throw new IllegalArgumentException("The scale must be a positive integer or zero");
    return new BigDecimal(Double.toString(paramDouble1)).divide(new BigDecimal(Double.toString(paramDouble2)), paramInt, 4).doubleValue();
  }

  public static double getDownValue(int paramInt)
  {
    double d = div(TrafficStats.getUidRxBytes(paramInt), 1024.0D, 2);
    if (d == 0.0D)
      d = 0.0D;
    return d;
  }

  public static String getTopUrl(String paramString)
  {
    Matcher localMatcher = Pattern.compile("(?<=http://|\\.)[^.]*?\\.(com|cn|net|org|biz|info|cc|tv)", 2).matcher(paramString);
    localMatcher.find();
    return localMatcher.group();
  }

  public static double getUpValue(int paramInt)
  {
    double d = div(TrafficStats.getUidTxBytes(paramInt), 1024.0D, 2);
    if (d == 0.0D)
      d = 0.0D;
    return d;
  }

  public static boolean isTopURL(String paramString)
  {
    String str = paramString.toLowerCase();
    return match("^((https|http|ftp|rtsp|mms)?://)?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?(([0-9]{1,3}\\.){3}[0-9]{1,3}|(www+\\.)?([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\\.(" + "com.cn|net.cn|org.cn|gov.cn|com.hk|公司|中国|网络|com|net|org|int|edu|gov|mil|arpa|Asia|biz|info|name|pro|coop|aero|museum|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cf|cg|ch|ci|ck|cl|cm|cn|co|cq|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|eh|es|et|ev|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gp|gr|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|ml|mm|mn|mo|mp|mq|mr|ms|mt|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|va|vc|ve|vg|vn|vu|wf|ws|ye|yu|za|zm|zr|zw" + "))" + "(:[0-9]{1,4})?" + "((/?)|" + "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$", str);
  }

  public static boolean isURL(String paramString)
  {
    return match("^((https|http|ftp|rtsp|mms)?://)?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?(([0-9]{1,3}\\.){3}[0-9]{1,3}|([0-9a-z_!~*'()-]+\\.)*([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\\.[a-z]{2,6})(:[0-9]{1,4})?((/?)|(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$", paramString.toLowerCase());
  }

  public static boolean isURL2(String paramString)
  {
    return match("^((https|http|ftp|rtsp|mms)?://)?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?(([0-9]{1,3}\\.){3}[0-9]{1,3}|([0-9a-z_!~*'()-]+\\.)*[a-z]{2,6})(:[0-9]{1,4})?((/?)|(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$", paramString);
  }

  private static boolean match(String paramString1, String paramString2)
  {
    return Pattern.compile(paramString1).matcher(paramString2).matches();
  }

  public static double mul(double paramDouble1, double paramDouble2)
  {
    return new BigDecimal(Double.toString(paramDouble1)).multiply(new BigDecimal(Double.toString(paramDouble2))).doubleValue();
  }

  public static double round(double paramDouble, int paramInt)
  {
    if (paramInt < 0)
      throw new IllegalArgumentException("The scale must be a positive integer or zero");
    return new BigDecimal(Double.toString(paramDouble)).divide(new BigDecimal("1"), paramInt, 4).doubleValue();
  }

  public static double sub(double paramDouble1, double paramDouble2)
  {
    return new BigDecimal(Double.toString(paramDouble1)).subtract(new BigDecimal(Double.toString(paramDouble2))).setScale(2, 4).doubleValue();
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.component.Arith
 * JD-Core Version:    0.6.2
 */